package com.yanchangapp.adapter;

import android.support.annotation.Nullable;
import android.text.TextUtils;
import android.view.View;
import android.widget.ImageView;
import android.widget.RelativeLayout;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.yanchangapp.R;
import com.yanchangapp.model.bean.PassApproveCommentBean;
import com.yanchangapp.widget.ExpandLayout;
import com.zxl.baselib.util.time.TimeUtil;
import com.zxl.baselib.util.ui.ResHelper;

import java.util.List;

/**
 * Created by apple on 2019-08-26.
 * description:记录里面评论adapter
 *
 * 布局一致...
 */
public class PassAvCommentAdapter extends BaseQuickAdapter<PassApproveCommentBean, BaseViewHolder> {

    public PassAvCommentAdapter(int layoutResId, @Nullable List<PassApproveCommentBean> data) {
        super(layoutResId, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, PassApproveCommentBean item) {
        helper.setText(R.id.tvUserName, ResHelper.getString(R.string.order_comment_user_name,
                item.getExamineEmployeeName()));
        // 设置时间咯
        helper.setText(R.id.tvTime, TimeUtil.getDayTime(item.getCreateTime()));
        helper.setText(R.id.tvCommentName,item.getExamineEmployeeName());
        helper.setText(R.id.tvCommentResult,item.getStatusName());
        String reason = "暂无";
        if (!TextUtils.isEmpty(item.getRemark())){
            reason = item.getRemark();
        }
        helper.setText(R.id.tvCommentContent,reason);
        ImageView ivArrow = helper.getView(R.id.ivArrow);
        ExpandLayout expandLayout = helper.getView(R.id.expandLayout);
        expandLayout.initExpand(false,ivArrow,true);
        RelativeLayout rlHead = helper.getView(R.id.rlHead);
        rlHead.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                expandLayout.toggleExpand();
            }
        });
    }
}
